import $getScript from './getScript'

let jsbridge
let jsBridgeSrc = '//s.yangshipin.cn/CCTVVideo/cctvh5-jsbridge/cctvh5-jsbridge.min.js'

export const getCCTVJsApi = () => {
	return new Promise((resolve) => {
		const options = {
			src: jsBridgeSrc,
			onLoad: () => {
				jsbridge = window['cctvh5-jsbridge'].default
				resolve()
			}
		}
		if (jsbridge) {
			resolve()
		} else {
			$getScript(options)
		}
	})
}

export { jsbridge }
